%$LuaTeX (encoding:utf-8)

% (c) Javier Bezos 2009
% License: LPPL.

% Requires luatex >= 0.40

\pdfoutput=1

\nonstopmode

% Go to line 113 to set a filter.

% Cada lista de nodos consiste en un párrafo (incluido \par). No se 
% ha aplicado kerning, pero si ligaduras.

% El paso por odvips da el error:
%   DVI file contains unexpected Omega command

\directlua{\unexpanded{
 local glyph = node.id('glyph')
 local disc = node.id('disc')
 local glue = node.id('glue')
 callback.register('pre_linebreak_filter',
   function(h, groupcode, glyphes)
     % texio.write_nl('= ')
     word = ''
     unword = ''
     full = false
     for t in node.traverse(h) do
       if full then
         if node.id(t.id) == glyph and t.subtype == 0 then
           word = word .. unicode.utf8.char(t.char)
         elseif node.id(t.id) == disc then
           word = word .. '-'
         end
       else
         if node.id(t.id) == glyph and t.subtype == 0 then
           unword = unword .. unicode.utf8.char(t.char)
         elseif node.id(t.id) == disc then
           unword = unword .. '-'
         elseif node.id(t.id) == glue then
           full = true
         end
       end
%        texio.write_nl('NODE type=' ..  node.type(t.id) .. ' subtype=' .. t.subtype )
%        if t.id == glyph then
%          texio.write(' font=' .. t.font .. ' char=' .. unicode.utf8.char(t.char))
%        end
       % for k, v in pairs(node.fields(t.id, t.subtype)) do
       %  if node.has_field(t, v) and t[v] and type(t[v]) ~= "userdata" then
       %    texio.write_nl('     -- ' .. v .. ': ' .. t[v])
       % end
       %end
     end
     if unword ~= word then
       texio.write_nl(word .. ' -- ' .. unword)
     end
     return true
   end)
}}

\catcode`\á=11 \lccode`\á=`\á
\catcode`\é=11 \lccode`\é=`\é
\catcode`\í=11 \lccode`\í=`\í
\catcode`\ó=11 \lccode`\ó=`\ó
\catcode`\ú=11 \lccode`\ú=`\ú
\catcode`\ñ=11 \lccode`\ñ=`\ñ

\newlanguage\base
\language\base

\patterns{
1ñ 2ñ.
1b 2b. 2bb 2bc 2bd 2bf 2bg 2b1h 2bj 2bk b2l 2bl. 2bm 2bn 2bp 2bq b2r 2br. 2bs 2bt 2bv 2bw 2bx 2by 2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ps 2pt 2pv 2pw 2px 2py 2pz
1q 2q. 2qb 2qc 2qd 2qf 2qg 2q1h 2qj 2qk 2ql 2qm 2qn 2qp 2qq 2qr 2qs 2qt 2qv 2qw 2qx 2qy 2qz
1r 2r. 2rb 2rc 2rd 2rf 2rg 2r1h 2rj 2rk 2rl 2rm 2rn 2rp 2rq r2r 2rr. 2rs 2rt 2rv 2rw 2rx 2ry 2rz
1s 2s. 2sb 2sc 2sd 2sf 2sg 2s1h 2sj 2sk 2sl 2sm 2sn 2sp 2sq 2sr 2ss 2st 2sv 2sw 2sx 2sy 2sz
1t 2t. 2tb 2tc 2td 2tf 2tg 2t1h 2tj 2tk 2tm 2tn 2tp 2tq t2r 2tr. 2ts 2tt 2tv 2tw t2x 2ty 2tz
1v 2v. 2vb 2vc 2vd 2vf 2vg 2v1h 2vj 2vk v2l 2vl. 2vm 2vn 2vp 2vq v2r 2vr. 2vs 2vt 2vv 2vw 2vx 2vy 2vz
1w 2w. 2wb 2wc 2wd 2wf 2wg 2w1h 2wj 2wk w2l 2wl. 2wm 2wn 2wp 2wq w2r 2wr. 2ws 2wt 2wv 2ww 2wx 2wy 2wz
1x 2x. 2xb 2xc 2xd 2xf 2xg 2x1h 2xj 2xk 2xl 2xm 2xn 2xp 2xq 2xr 2xs 2xt 2xv 2xw 2xx 2xy 2xz
1y 2y. 2yb 2yc 2yd 2yf 2yg 2y1h 2yj 2yk 2yl 2ym 2yn 2yp 2yq 2yr 2ys 2yt 2yv 2yw 2yx 2yy 2yz
1z 2z. 2zb 2zc 2zd 2zf 2zg 2z1h 2zj 2zk 2zl 2zm 2zn 2zp 2zq 2zr 2zs 2zt 2zv 2zw 2zx 2zy 2zz
2t2l}

\newlanguage\full
\language\full
\input eshyph.tex

\lefthyphenmin=1
\righthyphenmin=1

\font\tm=ptmr8t % Actually, any font with 256 chars
\tm
\pdfnoligatures\tm

\hbadness=10000
\hfuzz=\maxdimen

% The space serves as separator (a glue node)
\def\p#1{\setbox0\vbox{\hsize0pt\language\base #1 \language\full #1}}

\directlua{\unexpanded{
  local words = io.open('spanish-words.txt')
  for w in words:lines() do
    if w:find('inasis') then
      tex.print('\\p{' .. w .. '}')
    end
   end
   words:close()}}

\bye